package com.taotao.wifepojie.test;

import java.math.BigInteger;
import java.security.KeyStore;
import java.util.Map;
import java.util.Map.Entry;

/**求幂
 * @author wangjin
 * @title: MayiktHashMap
 * @projectName wife-pojie
 * @description: TODO
 * @date 2022/4/18 0018 15:42
 */
public class MayiktHashMap<K, V> {
    private Entry[] objects = new Entry[10000];

    class Entry<K, V> {
        K k;
        V v;
        Entry<K, V> next;

        public Entry(K k, V v) {
            this.k = k;
            this.v = v;
        }
    }
        public void put(K k, V v) {
            int index = k.hashCode() % objects.length;
            Entry<K, V> oldEntry = objects[index];
            if (oldEntry == null) {
                objects[index] = new Entry<K, V>(k, v);
            } else {
                oldEntry.next = new Entry<K, V>(k, v);
            }
        }

        public V get(K k) {
            int index = k.hashCode() % objects.length;
            for (Entry<K, V> entry = objects[index]; entry != null; entry = entry.next) {
                if (entry.k.equals(k) || entry.k == null) {
                    return entry.v;
                }
            }
            return null;
        }



    public static void main(String[] args) {
       /* MayiktHashMap mayiktHashMap=new MayiktHashMap();
        mayiktHashMap.put("a","a");
        mayiktHashMap.put(97,97);
        System.out.println(mayiktHashMap.get("a"));
        System.out.println(mayiktHashMap.get(97));
        BigInteger pow = BigInteger.valueOf(2).pow(10000);
        System.out.println(pow);*/

        System.out.println(highestOneBit(17));
    }
    public static int highestOneBit(int i) {
        // HD, Figure 3-1
        i |= (i >>  1);
        i |= (i >>  2);
        i |= (i >>  4);
        i |= (i >>  8);
        i |= (i >> 16);
       int j= i - (i >>> 1);
        return j*2;
    }


}
